package com.qidian.mes.service.impl;

import com.qidian.mes.mapper.ProcessContentMapper;
import com.qidian.mes.pojo.ProcessContent;
import com.qidian.mes.service.ProcessContentService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class ProcessContentServiceImpl implements ProcessContentService {
    @Autowired
    private ProcessContentMapper processContentMapper;
    @Override
    public MESResult list(Long processId) {
        return MESResult.ok(processContentMapper.list(processId));
    }

    @Override
    public MESResult save(ProcessContent processContent) {
        if (processContentMapper.getByProcessContentorderNum(processContent.getOrderNum()) !=null){
            return MESResult.duplicate("顺序重复");
        }
        processContentMapper.save(processContent);
        return MESResult.ok();
    }

    @Override
    public MESResult delete(Long contentId) {
        processContentMapper.deleteByContentId(contentId);
        return MESResult.ok();
    }

    @Override
    public MESResult get(Long contentId) {
        ProcessContent processContent =null;
        if ((processContent=processContentMapper.selectByContentId(contentId)) !=null){
            return MESResult.ok(processContent);
        }
        return MESResult.empty();
    }

    @Override
    public MESResult update(ProcessContent processContent) {
        processContentMapper.update(processContent);
        return MESResult.ok();
    }


}
